//
//  HomeHttpClient.m
//  weiMeiPhoto
//
//  Created by hff on 15/11/25.
//  Copyright (c) 2015年 threeTi. All rights reserved.
//

#import "HomeHttpClient.h"
#import "NSMutableDictionary+Utils.h"
#import "NSString+Category.h"


#define REQUEST_ADDRESS  @""



@implementation HomeHttpClient
static HomeHttpClient *instance = nil;

#define REQUEST_SIGN  [self createRequestSign:params]

//单例
+(HomeHttpClient *)shareInstance{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[HomeHttpClient alloc] init];
    });
    
    return instance;
}


#pragma mark - 帮助中心

//帮助视频类型
- (void)requestHelpTypeWithSuccess:(TTIClientManagerBlock)success
                           failuer:(TTIClientManagerBlock)failure
{
 
    NSString *URLstring = [NSString stringWithFormat:@"%@",@"m/help/findHelpType"];
    
//    [self.manager POST:URLstring parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
//
//        [self parseResponse:responseObject operation:operation success:success failure:failure];
//
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        [self parseResponse:operation.responseObject operation:operation success:success failure:failure];
//    }];
    
    [self.manager POST:URLstring parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        [self parseResponse:responseObject operation:task success:success failure:failure];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self parseResponse:task operation:task success:success failure:failure];
    }];
}


//相关类型视频列表
- (void)requestHelpListWithNextPage:(NSString *)nextPage
                           pageSize:(NSString *)pageSize
                          videotype:(NSString *)videotype
                            success:(TTIClientManagerBlock)success
                            failuer:(TTIClientManagerBlock)failure
{
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params addUnEmptyString:nextPage    forKey:@"nextPage"];
    [params addUnEmptyString:pageSize    forKey:@"pageSize"];
    [params addUnEmptyString:videotype    forKey:@"videotype"];
    
    NSString *URLstring = [NSString stringWithFormat:@"%@",@"m/help/findHelpList"];
    
//    [self.manager POST:URLstring parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
//
//        [self parseResponse:responseObject operation:operation success:success failure:failure];
//
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        [self parseResponse:operation.responseObject operation:operation success:success failure:failure];
//    }];
    [self.manager POST:URLstring parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        [self parseResponse:responseObject operation:task success:success failure:failure];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self parseResponse:task operation:task success:success failure:failure];
    }];
}


//帮助详细
- (void)requestHelpDetialWithModelId:(NSString *)modelId
                             success:(TTIClientManagerBlock)success
                             failuer:(TTIClientManagerBlock)failure
{
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params addUnEmptyString:modelId    forKey:@"modelId"];
   
    NSString *URLstring = [NSString stringWithFormat:@"%@",@"m/help/findHelpById"];
    
//    [self.manager POST:URLstring parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
//
//        [self parseResponse:responseObject operation:operation success:success failure:failure];
//
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        [self parseResponse:operation.responseObject operation:operation success:success failure:failure];
//    }];
    [self.manager POST:URLstring parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        [self parseResponse:responseObject operation:task success:success failure:failure];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self parseResponse:task operation:task success:success failure:failure];
    }];
}



#pragma mark - 注册鉴权码
- (void)requestRegistflyAuthenticationWithMsgNo:(NSString *)msgNo
                                        flyerNo:(NSString *)flyerNo
                                        provinceId:(NSString *)provinceId
                                        cityId:(NSString *)cityId
                                        makerId:(NSString *)makerId
                                        flyerType:(NSString *)flyerType
                                       success:(TTIClientManagerBlock)success
                                       failure:(TTIClientManagerBlock)failure
{
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params addUnEmptyString:msgNo    forKey:@"msgNo"];
    [params addUnEmptyString:flyerNo    forKey:@"flyerNo"];
    [params addUnEmptyString:provinceId    forKey:@"provinceId"];
    [params addUnEmptyString:cityId    forKey:@"cityId"];
    [params addUnEmptyString:makerId    forKey:@"makerId"];
    [params addUnEmptyString:flyerType    forKey:@"flyerType"];
    
    NSString *URLstring = [NSString stringWithFormat:@"%@",@"m/flyAuthentication/createFlyAuthentication"];
    
//    [self.manager POST:URLstring parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        
//        [self parseResponse:responseObject operation:operation success:success failure:failure];
//        
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        [self parseResponse:operation.responseObject operation:operation success:success failure:failure];
//    }];

}

@end
